package com.liuyfly.leetcode.questions;

import com.liuyfly.leetcode.util.LeetcodeUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @author liuyangfang at 2022-08-23 18:30
 */
@Slf4j
public class Question0782 {
    public static int movesToChessboard(int[][] board) {
        int move = 0;
        int rowOneCount = 0;
        int rowZeroCount = 0;
        int columnOneCount = 0;
        int columnZeroCount = 0;
        for (int j = 0; j < board.length; j++) {
            if (board[0][j] == 0) {
                rowZeroCount++;
            } else {
                rowOneCount++;
            }
            if (board[j][0] == 0) {
                columnZeroCount++;
            } else {
                columnOneCount++;
            }
        }

        if (Math.abs(rowOneCount - rowZeroCount) > 1) {
            return -1;
        }
        if (Math.abs(columnOneCount - columnZeroCount) > 1) {
            return -1;
        }

        return move;
    }

    private static void exchange(int[][] board, int first, int second, boolean row) {
        if (row) {

        }
    }

    public static void main(String[] args) {
        int[][] array = { { 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 1, 0, 0, 1 }, { 1, 0, 0, 1 } };
        LeetcodeUtil.printTwoDimensionalArray(array);
        int result = movesToChessboard(array);
        log.info("result:{}", result);
    }
}
